<h1><?php echo $this->translate('Translations'); ?></h1>
<div style="margin-bottom: 10px; font-size: 16px; font-weight: bold; text-transform: uppercase;">
    <?php
    $langs = array_keys(Light_Core::getTranslations());
    $n     = count($langs);
    foreach ($langs as $k => $lang) :
        if ($this->selectedLanguage == $lang) :
            echo $lang;
        else:
    ?>
        <a href="<?php echo $this->url(array('selectedLanguage' => $lang)); ?>"><?php echo $lang; ?></a>
    <?php
        endif;
        if ($k < $n - 1) :
            echo ' | ';
        endif;
    endforeach;
    ?>
</div>
<form action="<?php echo $this->url(); ?>" method="POST">
    <table class="form" style="border: 1px Lightid #134385;">
        <tr>
            <td>
                <label><?php echo $this->translate('File'); ?></label>
                <select name="section">
                <?php foreach (array_keys($this->selectedTranslations) as $tr) : ?>
                    <option value="<?php echo $tr; ?>"><?php echo $tr; ?></option>
                <?php endforeach; ?>
                </select>
            </td>
        </tr>
        <tr>
            <td>
            	<label><?php echo $this->translate('Key'); ?></label>
            	<input type="text" name="key" value="" />
            	<?php if (isset($this->errors['key']) && $this->errors['key']) : ?>
		        <ul class="errors"><li><?php echo $this->errors['key']; ?></li></ul>
		        <?php endif; ?>
            </td>
        </tr>
        <tr>
            <td>
            	<label><?php echo $this->translate('Value'); ?></label>
            	<input type="text" name="value" value="" />
            </td>
        </tr>
        <tr>
            <td><input type="submit" name="add" style="float: left;" value="&nbsp;&nbsp;<?php echo $this->translate('Add'); ?>&nbsp;&nbsp;" /></td>
        </tr>
    </table>
</form>
<?php foreach ($this->selectedTranslations as $section => $values) : ?>
<form action="<?php echo $this->url(); ?>" method="POST" style="margin-top: 15px;">
    <h2><?php echo $section; ?></h2>
    <table class="form" style="border: 1px Lightid #134385;">
        <tr>
            <th style="width: 15%; color: #fff; padding: 8px; background: none repeat scroll 0 0 #134385"><?php echo $this->translate('Key'); ?></th>
            <th style="width: 70%; color: #fff; padding: 8px; background: none repeat scroll 0 0 #134385"><?php echo $this->translate('Value'); ?></th>
            <th style="color: #fff; padding: 8px; background: none repeat scroll 0 0 #134385">
                <div style="width: 150px;">
                    <?php echo $this->translate('Action'); ?>
                </div>
            </th>
        </tr>
        <?php foreach ($values as $key => $value) : ?>
        <tr>
            <td>
                <?php echo $key; ?>
            </td>
            <td>
                <input type="text" name="translations[<?php echo $section; ?>][<?php echo $key; ?>]" value="<?php echo $value; ?>" />
            </td>
            <td>
                <input type="submit" style="float: none; margin: 0;" name="save" value="<?php echo $this->translate('Edit'); ?>" />
                &nbsp;<img class="remove" data-section="<?php echo $section; ?>" data-key="<?php echo $key; ?>" style="cursor: pointer; padding-right: 5px; vertical-align: middle;" alt="<?php echo $this->translate('Delete'); ?>" title="<?php echo $this->translate('Delete'); ?>" src="<?php echo LIGHT_ASSETS_URL; ?>/images/icons/32/Delete.png" />
            </td>
        </tr>
        <?php endforeach; ?>
    </table>
    <input type="hidden" name="deleteKey" />
    <input type="hidden" name="deleteSection" />
</form>
<?php endforeach; ?>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function () {
    $('.remove').bind('click', function () {
    	if (confirm('<?php echo $this->translate('Are you sure'); ?>')) {
        	var form = $(this).closest('form');
        	form.find('input[name="deleteKey"]').val($(this).attr('data-key'));
        	form.find('input[name="deleteSection"]').val($(this).attr('data-section'));
            $(this).closest('form').submit();
        }
        return false;
	});
});
//]]>
</script>